package com.dk.service.impl;


import com.dk.mapper.RightsMapper;
import com.dk.pojo.Rights;
import com.dk.service.RightsService;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RigthsServiceImpl implements RightsService {
    @Autowired
    private RightsMapper rightsMapper;
    @Override
    public List<Rights> getInfo() {
        return rightsMapper.selectByExample(null);
    }

    @Override
    public PageInfo<Rights> show(Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<Rights> list = rightsMapper.selectByExample(null);
        PageInfo<Rights> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public boolean addInfo(Rights rights) {
        return rightsMapper.insert(rights) > 0;
    }

    @Override
    public Rights toUpdatet(Integer id) {
        return rightsMapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean updateInfo(Rights rights) {
        return rightsMapper.updateByPrimaryKey(rights) > 0;
    }

    @Override
    public boolean deleteInfo(Integer id) {
        return rightsMapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public Rights selectById(Integer id) {
        return rightsMapper.selectByPrimaryKey(id);
    }
}
